<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>fetch</title>
</head>

<body>
    <button>使用fetch函数发送ajax请求</button>
    <script>
        const btn = document.querySelector('button');
        btn.onclick = function() {
            fetch('http://127.0.0.1:8000/fetch?vip=10', {
                method: 'POST',
                headers: {
                    id: 100,
                    name: 'atguigu'
                },
                body: 'uname = admin & password = admin',
            }).then(res => {
                return res.json();
            }).then(res => {
                console.log(res);
            })
        }
    </script>
</body>

</html>